home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
__MANDEL
/
MANDELBR
/
CMANDELC.C
< prev
next >
Wrap
Text File
|
1992-03-28
|
2KB
|
97 lines
// CMandelCheckPhase.c
#include "CMandelCheckPhase.h"
#include "CMandelDividePhase.h"
void
CMandelCheckPhase::IMandelCheckPhase(CMandelDoc *theDoc, CMandelPhase *theNextPhase,
Rect theRect)
{
CMandelPhase::IMandelPhase(theDoc, theNextPhase);
itsRect = theRect;
}
CMandelPhase *
CMandelCheckPhase::Perform(void)
{
TDwell aDwell;
if (CheckRect(&aDwell))
FillRect(aDwell);
else
{
CMandelDividePhase * aDividePhase;
aDividePhase = new CMandelDividePhase;
aDividePhase->IMandelDividePhase(itsDoc, itsNextPhase, itsRect);
itsNextPhase = aDividePhase;
}
return itsNextPhase;
}
Boolean
CMandelCheckPhase::CheckRect(TDwell *theDwell)
{
TDwell aDwell, *aDwellP, *aDwellQ, *aDwellPtr = *itsDoc->itsDwellsH;
short aMapWidth = itsDoc->itsWidth;
aDwellP = aDwellQ = aDwellPtr + (long)itsRect.top * aMapWidth;
aDwellP += itsRect.left;
aDwellQ += itsRect.right;
aDwell = *aDwellP++;
while (aDwellP <= aDwellQ)
if (*aDwellP++ != aDwell)
return FALSE;
aDwellP = aDwellQ = aDwellPtr + (long)itsRect.bottom * aMapWidth;
aDwellP += itsRect.left;
aDwellQ += itsRect.right;
while (aDwellP <= aDwellQ)
if (*aDwellP++ != aDwell)
return FALSE;
aDwellP = aDwellPtr + (long)itsRect.top * aMapWidth + itsRect.left;
aDwellQ = aDwellPtr + (long)itsRect.bottom * aMapWidth + itsRect.left;
for (aDwellP += aMapWidth; aDwellP < aDwellQ; aDwellP += aMapWidth)
if (*aDwellP != aDwell)
return FALSE;
aDwellP = aDwellPtr + (long)itsRect.top * aMapWidth + itsRect.right;
aDwellQ = aDwellPtr + (long)itsRect.bottom * aMapWidth + itsRect.right;
for (aDwellP += aMapWidth; aDwellP < aDwellQ; aDwellP += aMapWidth)
if (*aDwellP != aDwell)
return FALSE;
*theDwell = aDwell;
return TRUE;
}
void
CMandelCheckPhase::FillRect(TDwell theDwell)
{
TDwell * aDwellP, *aDwellQ, *aP, *aQ, *aDwellPtr = *itsDoc->itsDwellsH;
unsigned aMapWidth, h, v;
aMapWidth = itsDoc->itsWidth;
aDwellP = aDwellQ = aDwellPtr + itsRect.left + 1;
aDwellP += (long)(itsRect.top + 1) * aMapWidth;
aDwellQ += (long)(itsRect.bottom - 1) * aMapWidth;
aQ = aDwellPtr + itsRect.right - 1;
aQ += (long)(itsRect.top + 1) * aMapWidth;
while (aDwellP <= aDwellQ)
{
aP = aDwellP;
while (aP <= aQ)
*aP++ = theDwell;
aDwellP += aMapWidth;
aQ += aMapWidth;
}
}